package com.zide.link.mapper;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zide.framework.config.mybatisplus.XianYingMapperPlus;
import com.zide.link.domain.po.LinkWeb;
import com.zide.link.domain.vo.search.LinkWebSearchVO;
import org.apache.ibatis.annotations.Mapper;
import com.zide.common.core.domain.PageResult;

/**
 * 外链网站Mapper接口
 * 
 * @author zide
 * @date 2024-05-10
 */
@Mapper
public interface LinkWebMapper extends XianYingMapperPlus<LinkWeb> {

    default PageResult<LinkWeb> selectPage(LinkWebSearchVO searchVO) {
        LambdaQueryWrapper<LinkWeb> wrapper = new LambdaQueryWrapper<>();
        if(ObjectUtil.isNotNull(searchVO.getType())) {
            wrapper.eq(LinkWeb::getType,searchVO.getType());
        }
        if(StrUtil.isNotEmpty(searchVO.getTitle())) {
            wrapper.like(LinkWeb::getTitle,searchVO.getTitle());
        }
        wrapper.orderByDesc(LinkWeb::getId);
        return selectPage(searchVO, wrapper);
    }
}
